<template>
  <a-layout>
    <a-layout-header class="header">
      <div class="logo" />
      <a-menu
        theme="dark"
        mode="horizontal"
        @click="menuClick"
        v-model:selectedKeys="selectedKeys1"
        :style="{ lineHeight: '64px' }"
      >
        <a-menu-item v-for="(item, key) in menus" v-bind:key="key">
          {{ item.name }}</a-menu-item
        >
      </a-menu>
    </a-layout-header>
    <router-view :key="$route.fullPath" />
  </a-layout>
</template>
<script lang="ts">
import { defineComponent, ref } from "vue";
import { getMenus } from "@/api/user";

export default defineComponent({
  components: {},
  data() {
    return {
      menus: getMenus(),
    };
  },
  setup() {
    return {
      selectedKeys1: ref<string[]>(["2"]),
      selectedKeys2: ref<string[]>(["1"]),
      collapsed: ref<boolean>(false),
      openKeys: ref<string[]>(["sub1"]),
    };
  },
  methods: {
    menuClick(e) {
      let m = this.menus[e.key];
      this.$router.push({ path: `/${m.id}`, replace: true });
    },
  },
});
</script>
<style>
#components-layout-demo-top-side-2 .logo {
  float: left;
  width: 120px;
  height: 31px;
  margin: 16px 24px 16px 0;
  background: rgba(255, 255, 255, 0.3);
}

.ant-row-rtl #components-layout-demo-top-side-2 .logo {
  float: right;
  margin: 16px 0 16px 24px;
}

.site-layout-background {
  background: #fff;
}
</style>
